// MathJax 插件实现

CKEDITOR.plugins.add('mathjax', {
    requires: 'dialog',
    icons: 'mathjax',
    init: function(editor) {
        // 添加命令
        editor.addCommand('mathjax', new CKEDITOR.dialogCommand('mathjaxDialog'));
        editor.config.pasteFromOfficeUploadImage = true;
        // 添加按钮
        editor.ui.addButton('MathJax', {
            label: '插入公式',
            command: 'mathjax',
            toolbar: 'insert',
            icon: this.path + 'icons/mathjax.png'  // 需要添加图标
        });

        // 注册对话框
        CKEDITOR.dialog.add('mathjaxDialog', this.path + 'dialogs/mathjax.js');

        // 配置 MathJax
        if (!window.MathJax) {
            window.MathJax = {
                tex: {
                    inlineMath: [ ['$', '$'], ['\\(', '\\)'] ],
                    displayMath: [ ['$$', '$$'], ['\\[', '\\]'] ],
                    processEscapes: true
                },
                svg: {
                    fontCache: 'global'
                }
            };
        }
    }
});